<script type="text/javascript" src="{$base_dir}modules/general_emr/js/AJAX_Odonto_Stomatology.js"></script>
{literal}
<style type="text/css">
	strong {
		color: red;
	}
</style>

<script type="text/javascript">
var khdtTongQuat = ['Nhổ răng', 'Chữa răng', 'Tiểu phẫu thuật', 'Nha chu', 'Phục hình','Nha trẻ em','Chỉnh hình răng','Lão nha','Implant'];

$(document).ready(function(){	
	// Register Autocomplete for doctor name
	var doctorAC = $('#doctorName').autocomplete('../Employee/GetDoctorAutoCompleteAjax?set_ajax_view');
	doctorAC.setOptions({
        width: 			195,
        minChars:		2,
        formatItem:		formatMatch                                                                                                             
    });	

	// Fill data for doctor name autocomplete result
	$('#doctorName').result(function(event, data, formatted) {
		$(this).val(data[0]);
		$('#doctorId').val(data[2]);	
	});	

	$(".khdtTq").autocomplete(khdtTongQuat, {
        minChars: 0,
        max: 12,
        mustMatch: true,
        matchContains: false,
        scrollHeight: 220
    });
    
});

//Format data result for service code autocomplete
function formatMatch(item) {		
	return item[0] + '<br /><i>' + item[1] + '</i>';
}

</script>
{/literal}

<div id='clinDiagEdit' style='display: block;'>
    
    <form id='frmClinDiagEdit' action=''>
        <input type='hidden' name='recordId' id='recordId' value='{$recordId}'>        
        <span id='statusMessageClinDiag' class='formAlertMsg'></span> 
        
        <div class="field-row">
            <div class="field-label">{translate}Reason{/translate}</div>
            <div class="field-value" style="width: 430px;">
				<input type="text" style="width: 280px;" id="reason" name="profile[reason]" value="{$emr->get('reason')}" />&nbsp;
            </div>
            <div class="field-label">{translate}Treatment doctor{/translate}</div>
        	<div class="field-value" style="width: 225px;">
        		<input id="doctorId" type="hidden" name="profile[doctor_id]" value="{$doctorId}">
	    		<input id="doctorName" name="doctorName" type="text" value="{$doctorName}" style="width: 220px;" >
	    		&nbsp;
	    		              
        	</div>                
            <div style="clear: both;"></div>
        </div>
        <div class="field-row" style="height: 60px;">
	        <div class="field-label">{translate}Medical history{/translate}</div>
	        <div class="field-value">
	            <textarea rows="2" style="width: 284px; height: 40px;" id="medicalHistory" name="profile[medical_history]">{$emr->get('medical_history')}</textarea>
	        </div>                
	        <div style="clear: both;"></div>
        </div>
        <div style="float: left;width: 470px;" >
			<div class="documentListHeader" style="background: none; margin-bottom: 10px; border-width: 0 0 1px 0;"><span>{translate}General health{/translate}</span></div>
			<div class="field-row" >
				<div class="field-label">{translate}Blood pressure:{/translate}</div>
	            <div class="field-value" style="width: 290px;">
	                <input	type="text" style="width: 280px;" name="profile[ttsk_ha]" id="ttskHa" id="ttskHa" value="{$emr->get('ttsk_ha')}" />&nbsp;
	            </div>
	            <div class="field-value">	
				{if $emr->get('ttsk_ha_checked') == 1}                
					<input id="ttskHaCheck" name="profile[ttsk_ha_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="ttskHaCheck" name="profile[ttsk_ha_checked]" type="checkbox" />&nbsp;
				{/if}
	            </div>
	            <div style="clear: both;"></div>
			</div> 
	        <div class="field-row">
	            <div class="field-label">{translate}Cardiovascular{/translate}</div>
	            <div class="field-value" style="width: 290px;">
                    <input type="text" style="width: 280px;" id="ttskBtm" name="profile[ttsk_btm]" value="{$emr->get('ttsk_btm')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('ttsk_btm_checked') == 1}                
					<input id="ttskBtmCheck" name="profile[ttsk_btm_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="ttskBtmCheck" name="profile[ttsk_btm_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div> 
	        <div class="field-row">
	            <div class="field-label">{translate}Diabetes{/translate}</div>
	            <div class="field-value" style="width: 290px;">
                    <input type="text" style="width: 280px;" name="profile[ttsk_td]" id="ttskTd" value="{$emr->get('ttsk_td')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('ttsk_td_checked') == 1}                
					<input id="ttskTdCheck" name="profile[ttsk_td_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="ttskTdCheck" name="profile[ttsk_td_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div> 
	        <div class="field-row">
	            <div class="field-label">{translate}Long bleeding{/translate}</div>
	            <div class="field-value" style="width: 290px;">
                    <input type="text" style="width: 280px;" id="ttskCml" name="profile[ttsk_cml]" value="{$emr->get('ttsk_cml')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('ttsk_cml_checked') == 1}                
					<input id="ttskCmlCheck" name="profile[ttsk_cml_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="ttskCmlCheck" name="profile[ttsk_cml_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div> 
	        <div class="field-row">
	            <div class="field-label">{translate}Liver{/translate}</div>
	            <div class="field-value" style="width: 290px;">
                    <input type="text" style="width: 280px;" id="ttskBg" name="profile[ttsk_bg]" value="{$emr->get('ttsk_bg')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('ttsk_bg_checked') == 1}                
					<input id="ttskBgCheck" name="profile[ttsk_bg_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="ttskBgCheck" name="profile[ttsk_bg_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div> 
	        <div class="field-row">
	            <div class="field-label" style="width: 200px; ">{translate}Allergy(anaesthetic, antibiotic){/translate}</div>
	            <div class="field-value" style="width: 240px;">
                    <input type="text" style="width: 230px;" id="ttskDut" name="profile[ttsk_dut]" value="{$emr->get('ttsk_dut')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('ttsk_dut_checked') == 1}                
					<input id="ttskDutCheck" name="profile[ttsk_dut_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="ttskDutCheck" name="profile[ttsk_dut_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div> 
	        <div class="field-row">
	            <div class="field-label" style="width: 200px;">{translate}Neuropathy{/translate}</div>
	            <div class="field-value" style="width: 240px;">
                    <input type="text" style="width: 230px;" id="ttskBtk" name="profile[ttsk_btk]" value="{$emr->get('ttsk_btk')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('ttsk_btk_checked') == 1}                
					<input id="ttskBtkCheck" name="profile[ttsk_btk_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="ttskBtkCheck" name="profile[ttsk_btk_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div> 
	        <div class="field-row">
	            <div class="field-label">{translate}Pneumopathy(tuberculosis, asthma){/translate}</div>
	            <div class="field-value" style="width: 290px;">
                    <input type="text" style="width: 280px;" id="ttskBp" name="profile[ttsk_bp]" value="{$emr->get('ttsk_bp')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('ttsk_bp_checked') == 1}                
					<input id="ttskBpCheck" name="profile[ttsk_bp_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="ttskBpCheck" name="profile[ttsk_bp_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div> 
	        <div class="field-row">
	            <div class="field-label">{translate}Cyesis, catamenia{/translate}</div>
	            <div class="field-value" style="width: 290px;">
                    <input type="text" style="width: 280px;" id="ttskTkn" name="profile[ttsk_tkn]" value="{$emr->get('ttsk_tkn')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('ttsk_tkn_checked') == 1}                
					<input id="ttskTknCheck" name="profile[ttsk_tkn_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="ttskTknCheck" name="profile[ttsk_tkn_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div> 
	        <div class="field-row">
	            <div class="field-label">{translate}Undergoing medical treatment{/translate}</div>
	            <div class="field-value" style="width: 290px;">
                    <input type="text" style="width: 280px;" id="ttskBddt" name="profile[ttsk_bddt]" value="{$emr->get('ttsk_bddt')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('ttsk_bddt_checked') == 1}                
					<input id="ttskBddtCheck" name="profile[ttsk_bddt_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="ttskBddtCheck" name="profile[ttsk_bddt_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div> 
	        <div class="field-row">
	            <div class="field-label">{translate}Medical speciality{/translate}</div>
	            <div class="field-value" style="width: 290px;">
                    <input type="text" style="width: 280px;" id="ttskKcky" name="profile[ttsk_kcky]" value="{$emr->get('ttsk_kcky')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('ttsk_kcky_checked') == 1}                
					<input id="ttskKckyCheck" name="profile[ttsk_kcky_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="ttskKckyCheck" name="profile[ttsk_kcky_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div> 
	        <div class="documentListHeader" style="background: none; margin: 10px 0px; border-width: 0 0 1px 0;"><span style="font: bold;">{translate}Paraclinique{/translate}</span></div>
	       	<div class="field-row">
	            <div class="field-label">{translate}X-ray:{/translate}</div>
	            <div class="field-value" style="width: 290px;">
                    <input type="text" style="width: 280px;" id="clsXq" name="profile[cls_xq]" value="{$emr->get('cls_xq')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('cls_xq_checked') == 1}                
					<input id="ttskXqCheck" name="profile[cls_xq_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="ttskXqCheck" name="profile[cls_xq_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div> 
	        <div class="field-row">
	            <div class="field-label">{translate}Test:{/translate}</div>
	            <div class="field-value" style="width: 290px;">
                    <input type="text" style="width: 280px;" id="clsXn" name="profile[cls_xn]" value="{$emr->get('cls_xn')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('cls_xn_checked') == 1}                
					<input id="clsXnCheck" name="profile[cls_xn_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="clsXnCheck" name="profile[cls_xn_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div> 
	        <div class="field-row">
	            <div class="field-label">{translate}Other{/translate}</div>
	            <div class="field-value" style="width: 290px;">
                    <input type="text" style="width: 280px;" id="clsK" name="profile[cls_k]" value="{$emr->get('cls_k')}" />&nbsp;
                </div>
                <div class="field-value">   
				{if $emr->get('cls_k_checked') == 1}                
					<input id="clsKCheck" name="profile[cls_k_checked]" type="checkbox" checked="checked" />&nbsp;
				{else}
					<input id="clsKCheck" name="profile[cls_k_checked]" type="checkbox" />&nbsp;
				{/if}
                </div>
	            <div style="clear: both;"></div>
	        </div>
	        <div class="documentListHeader" style="background: none; margin: 10px 0px; border-width: 0 0 1px 0;"><span style="font: bold;">{translate}Treatment plan{/translate}</span></div>
	        {php}
	            $index = 1;
                $this->assign('index', $index);
            {/php}
	        {section name=i loop=$numberOfStep}    
                <div class="field-row">
                    <div class="field-label" style="text-align: right;">{$smarty.section.i.rownum}:&nbsp;&nbsp;</div>
                    <div class="field-value" style="width: 290px;">
                        <input type="text" class='khdtTq' style="width: 280px;" id="khdt{$smarty.section.i.rownum}" name="profile[khdt_{$smarty.section.i.rownum}]" value='{$emr->get("khdt_$index")}' />&nbsp;
                    </div>                
                    <div style="clear: both;"></div>
                </div>
                {php}
                    $this->assign('index', ++$index);
                {/php}
            {/section}
            
        </div>
        <div style="float:right; width: 475px;">           
            <div class="documentListHeader" style="background: none; margin: 0px 0px 10px 0px; border-width: 0 0 1px 0;"><span>{translate}Face examination{/translate}</span></div>
            <div class="field-row" style="height: 80px; width: 470px;">
				<textarea style="width:100%; height: 60px;" id="knm" name="profile[kham_ngoai_mat]">{$emr->get('kham_ngoai_mat')}</textarea>
            </div>
            <div class="documentListHeader" style="background: none; border-width: 0 0 1px 0;"><span>{translate}Dental examination{/translate}</span></div><br> 
            <div class="field-row" style="height: 346px; width: 470px;">                
                <div id='adultTeeth' style="height: 130px;" >
                	{$adultTeeth}	                   
                </div>
                 <div id='childTeeth' style="height: 130px;" >
                	{$childTeeth}	                   
                </div>
                <div class="field-value" style="height: 80px; width: 470px;">
                    <textarea style="width:100%; height: 60px;" id="ktm" name="profile[kham_trong_mieng]">{$emr->get('kham_trong_mieng')}</textarea>
                </div>                
                <div style="clear: both;"></div>
            </div>
            <div class="documentListHeader" style="background: none; margin: 10px 0px; border-width: 0 0 1px 0;"><span>{translate}Diagnosis{/translate}</span></div><br>
            <div class="field-row" style="height: 60px;">
                <div class="field-label">{translate}Main diagnosis{/translate}</div>
                <div class="field-value">
                    <input style='width: 80px' type="text" name="profile[icd10_chinh_code]" id="icd10Chinh" value="{$sec1Icd10->getCode()}" />
                    <input style='width: 340px' type="text" id="icd10Chinh_1" value="{$sec1Icd10->getLocalizedText('name')}" readonly="readonly" />
                    <button type="button" id="btnChinhIcd10">...</button>
                </div>
                <div style="clear: both;"></div>
            </div>
            <div class="field-row" style="height: 70px;">
                <div class="field-label">{translate}Auxiliary diagnosis{/translate}</div>
                <div class="field-value">
                    <input style='width: 80px' type="text" name="profile[icd10_phu_code]" id="icd10Phu" value="{$sec2Icd10->getCode()}" />
                    <input style='width: 340px' type="text" id="icd10Phu_1" value="{$sec2Icd10->getLocalizedText('name')}" readonly="readonly" />
                    <button type="button" id="btnPhuIcd10">...</button>
                </div>
                <div style="clear: both;"></div>
            </div>           
            <div class="field-row" style="height: 80px; width: 470px;">
				<textarea style="width:100%; height: 60px" id="cd" name="profile[chuan_doan]">{$emr->get('chuan_doan')}</textarea>
            </div>

        </div>       
        <div style="clear: both;"></div>

    </form>
    <div style='margin-top: 10px; text-align: right;'>
        <span id='statusMessageSave'></span>&nbsp;
        <input type="button" value="{translate}Save{/translate}" onclick="javascript:editOdontoStomatology();">
	</div>
{include file="icd_10/element_icd10_selector.html"}
</div>